package defaultSysConfig

import (
	"fmt"
	"saas_sys_base/common"
	. "saas_sys_base/modules/adminSaas/models"
	. "saas_sys_base/modules/system/models"
)

//平台默认菜单配置
//注意：父菜单MType需要配置为1， 子菜单Mtype需要配置为2（子菜单同时需要把Pid设为-1）
var G_SysMenulistDefault []SysMenu = []SysMenu{
	{Name: "运营管理", MType: 1, Pid: 0, Show: 1},
	/*2级菜单*/{Name: "用户管理", MType: 2, Pid: -1, Show: 1},
	{Name: "用户管理", MType: 1, Pid: 0, Show: 1},

	{Name: "APP管理", MType: 1, Pid: 0, Show: 1},
	/*2级菜单*/{Name: "APP配置", MType: 2, Pid: -1, Show: 1, Url: "/admin/AppAttr/listpage"},
	/*2级菜单*/{Name: "APP商品", MType: 2, Pid: -1, Show: 1, Url: "/admin/AppProduct/listpage"},

	{Name: "租户管理", MType: 1, Pid: 0, Show: 1},
	/*2级菜单*/{Name: "租户列表", MType: 2, Pid: -1, Show: 1, Url: "/admin/Tenant/listpage"},

	{Name: "配置管理", MType: 1, Pid: 0, Show: 1},

	{Name: "系统管理", MType: 1, Pid: 0, Show: 1},
	/*2级菜单*/{Name: "系统用户", MType: 2, Pid: -1, Show: 1, Url: "/admin/SysUser/listpage"},
	/*2级菜单*/{Name: "角色管理", MType: 2, Pid: -1, Show: 1, Url: "/admin/SysRole/listpage"},
	/*2级菜单*/{Name: "菜单管理", MType: 2, Pid: -1, Show: 1, Url: "/admin/SysMenu/listpage"},

	{Name: "系统管理2", MType: 1, Pid: 0, Show: 1},
	/*2级菜单*/{Name: "系统用户2", MType: 2, Pid: -1, Show: 1, Url: "/admin/SysUser/listpage"},
}

//saas租户端的菜单默认菜单配置
var G_AppMenulistDefault []AdminSaasMenu = []AdminSaasMenu{
	{Name: "租户APP管理", MType: 1, Pid: 0, Show: 1, MiniAppId: common.APP_ID_TENANT_WEAPP, MenuMode: common.MenuMode_Tenant},
	{Name: "用户管理", MType: 1, Pid: 0, Show: 1, MiniAppId: common.APP_ID_TENANT_WEAPP, MenuMode: common.MenuMode_Tenant},
	{Name: "会员卡管理", MType: 1, Pid: 0, Show: 1, MiniAppId: common.APP_ID_TENANT_WEAPP, MenuMode: common.MenuMode_Tenant},

	{Name: "商品管理", MType: 1, Pid: 0, Show: 1, MiniAppId: common.APP_ID_TENANT_WEAPP, MenuMode: common.MenuMode_Tenant},
	/*2级菜单*/{Name: "商品管理", MType: 2, Pid: -1, Show: 1, Url: "/admin/Product/tenantlistpage", MiniAppId: common.APP_ID_TENANT_WEAPP, MenuMode: common.MenuMode_Tenant},


	//微应用管理端菜单  <<<--------------------------------------------->>>
	//应用1001菜单配置   APP_ID_TENANT_WEAPP  = 1001 //商户端主微信小程序
	{Name: "产品管理", MType: 1, Pid: 0, Show: 1, MiniAppId: common.APP_ID_TENANT_WEAPP, MenuMode: common.MenuMode_MiniApp},
	/*2级菜单*/{Name: "APP商品", MType: 2, Pid: -1, Show: 1, Url: "/admin/AppProduct/listpage_app", MiniAppId: common.APP_ID_TENANT_WEAPP, MenuMode: common.MenuMode_MiniApp},

	{Name: "微应用订单", MType: 1, Pid: 0, Show: 1, MiniAppId: common.APP_ID_TENANT_WEAPP, MenuMode: common.MenuMode_MiniApp},
	/*2级菜单*/{Name: "已完成订单", MType: 2, Pid: -1, Show: 1, Url: "/admin/sysOders/SysOrders/finishlistpage_saas", MiniAppId: common.APP_ID_TENANT_WEAPP, MenuMode: common.MenuMode_MiniApp},
	/*2级菜单*/{Name: "已支付订单", MType: 2, Pid: -1, Show: 1, Url: "/admin/sysOders/SysOrders/paylistpage_saas", MiniAppId: common.APP_ID_TENANT_WEAPP, MenuMode: common.MenuMode_MiniApp},
	/*2级菜单*/{Name: "未支付订单", MType: 2, Pid: -1, Show: 1, Url: "/admin/sysOders/SysOrders/unpaylistpage_saas", MiniAppId: common.APP_ID_TENANT_WEAPP, MenuMode: common.MenuMode_MiniApp},

}

func CheckMenuConfig(menulist []SysMenu) {
	for _, menuConf := range menulist {
		if menuConf.MType != 1 && menuConf.MType != 2 {
			panic(fmt.Sprintf("menuConf.MType must be 1 or 2, but now it is <%d>", menuConf.MType))
		}

		if (menuConf.MType == 2 && menuConf.Pid != -1) ||
			(menuConf.MType != 2 && menuConf.Pid == -1) {
			panic("if menuConf.MType  2(submenu), pid must be -1")
		}

	}

}

